import React from 'react'
import Article from "../views/Course/Article";
import Category from "../views/Course/Category";
import DashBoard from "../views/DashBoard";
import {
  HomeOutlined,
  AppstoreOutlined
} from '@ant-design/icons';
import ArticlePub from '../views/Course/ArticlePub';
import Setting from '../views/Setting';
import MenuManager from '../views/Manager/MenuManager';
import RoleManager from '../views/Manager/RoleManager';
import UserManager from '../views/Manager/UserManager';
import AreaMap from '../views/AreaMap';
import BaiDuMap from '../views/AreaMap/BaiDuMap';

export const adminRoutes = [
  {
    path:'dashboard',
    element:<DashBoard/>,
    key:'dashboard',
    label:'系统首页',
    icon:<HomeOutlined/>,
    roles:['root']
  },
  {
    key:'course',
    label:'课程管理',
    icon:<AppstoreOutlined/>,
    roles:['root','admin'],
    children:[
      {
        path:'course/category',
        element:<Category/>,
        key:'course/category',
        label:'课程分类',
        roles:['root','admin'],
      },
      {
        path:'course/article',
        element:<Article/>,
        key:'course/article',
        label:'图文课程',
        roles:['root','admin'],
      },
      {
        path:'course/article/pub',
        element:<ArticlePub/>,
        key:'course/article/pub',
        label:'图文课程发布',
        roles:['root','admin'],
      }
    ]
  },
  {
    key:'manager',
    label:'系统管理',
    icon:<AppstoreOutlined/>,
    roles:['root'],
    children:[
      {
        path:'manager/menu',
        element:<MenuManager/>,
        key:'manager/menu',
        label:'菜单管理',
        roles:['root'],
      },
      {
        path:'manager/role',
        element:<RoleManager/>,
        key:'manager/role',
        label:'角色管理',
        roles:['root'],
      },
      {
        path:'manager/user',
        element:<UserManager/>,
        key:'manager/user',
        label:'账号管理',
        roles:['root'],
      },
    ]
  },
  {
    path:'setting',
    element:<Setting/>,
    key:'setting',
    label:'个人设置',
    icon:<HomeOutlined/>,
    roles:['root','admin','normal'],
  },
  {
    path:'area',
    element:<AreaMap/>,
    key:'area',
    label:'地图板块',
    icon:<HomeOutlined/>,
    roles:['root','admin','normal'],
  },
  {
    path:'bmap',
    element:<BaiDuMap/>,
    key:'bmap',
    label:'百度地图',
    icon:<HomeOutlined/>,
    roles:['root','admin','normal'],
  },
]

export const filterRoutes = ()=>{ //处理后的数据包用以动态渲染Route
  let routes = []
  adminRoutes.forEach(item=>{
    if(item.children){
      routes = [...routes,...item.children]
    }else{
      routes.push(item)
    }
  })
  return routes
}
